/*

import { useNavigate} from "react-router-dom"
function Car(){
    const tiao=useNavigate();


    return <div>
        <h1 onClick={()=>{
           tiao('/home')

        }}> 跳转到首页</h1>


        <h1 onClick={()=>tiao(-1)}> 后退</h1>


    </div>
}
export default Car

*/

import React, { Component } from 'react'

import {useParams,useLocation,useNavigate}  from "react-router-dom"
function withRouter(Component) {
    return (props) => (
      <Component
        {...props}
        params={useParams()}
        location={useLocation()}
        navigate={useNavigate()}
      />
    );
  }
  
 class Car extends Component {
  render() {
    return (
      <div>
        <h1 onClick={()=>{
            // console.log("aaaa")
            this.props.navigate('/home')
        }}>跳转到首页</h1>
        <h1 onClick={()=>this.props.navigate(-1)}>后退</h1>
      </div>
    )
  }
}

export default withRouter( Car)